package com.cy.pj.activity.service.impl;

import com.cy.pj.activity.dao.ActivityDao;
import com.cy.pj.activity.pojo.Activity;
import com.cy.pj.activity.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author LiuXu
 * @create 2020-07-04 15:22
 */

@Service
public class ActivityServiceImpl implements ActivityService {
    @Autowired
    private ActivityDao activityDao;

    @Override
    public Activity findById(Integer id) {
        return activityDao.findById(id);
    }

    @Override
    public int deleteById(Integer id) {
        //System.out.println();

        return activityDao.deleteById(id);

    }

    @Override
    public int saveActivity(Activity entity) {
        if (entity.getId() == null) {
            return activityDao.insertActivity(entity);
        } else {
            return activityDao.updateActivity(entity);
        }
    }

    @Override
    public List<Activity> findActivitys() {
        //try{Thread.sleep(5000);}
        //catch (Exception e) {e.printStackTrace();}
        return activityDao.findActivitys();
    }

}